
<h2>
  <?php echo $this->translate("Webmix Plugin") ?>
</h2>

<?php if( count($this->navigation) ): ?>
  <div class='tabs'>
    <?php
      // Render the menu
      //->setUlClass()
      echo $this->navigation()->menu()->setContainer($this->navigation)->render()
    ?>
  </div>
<?php endif; ?>

<p>
  <?php echo $this->translate('') ?>
</p>

<br />

<script type="text/javascript">
  var currentOrder = '<?php echo $this->order ?>';
  var currentOrderDirection = '<?php echo $this->order_direction ?>';
  var changeOrder = function(order, default_direction){
    // Just change direction
    if( order == currentOrder ) {
      $('order_direction').value = ( currentOrderDirection == 'ASC' ? 'DESC' : 'ASC' );
    } else {
      $('order').value = order;
      $('order_direction').value = default_direction;
    }
    $('filter_form').submit();
  }

function multiModify()
{
  var multimodify_form = $('multimodify_form');
  if (multimodify_form.submit_button.value == 'delete')
  {
    return confirm('<?php echo $this->string()->escapeJavascript($this->translate("Are you sure you want to delete the selected webmixes?")) ?>');
  }
}

function selectAll()
{
  var i;
  var multimodify_form = $('multimodify_form');
  var inputs = multimodify_form.elements;
  for (i = 1; i < inputs.length - 1; i++) {
    if (!inputs[i].disabled) {
      inputs[i].checked = inputs[0].checked;
    }
  }
}


</script>

<div class='admin_search'>
  <?php echo $this->formFilter->render($this) ?>
</div>

<br />

 <?php echo $this->htmlLink(array('route' => 'webmix_special', 'action' => 'create'), $this->translate('Add New Webmix'), array(
      'class' => 'smoothbox buttonlink',
      'style' => 'background-image: url(' . $this->layout()->staticBaseUrl . 'application/modules/Core/externals/images/admin/new_category.png);')) ?>
      <br />
      <br />
<div class='admin_results'>
  <div>
    <?php $count = $this->paginator->getTotalItemCount() ?>
    <?php echo $this->translate(array("%s webmix found", "%s webmixes found", $count),
        $this->locale()->toNumber($count)) ?>
  </div>
  <div>
    <?php echo $this->paginationControl($this->paginator, null, null, array(
      'pageAsQuery' => true,
      'query' => $this->formValues,
      //'params' => $this->formValues,
    )); ?>
  </div>
</div>

<br />


<div class="admin_table_form">
<form id='multimodify_form' method="post" action="<?php echo $this->url(array('action'=>'multi-modify'));?>" onSubmit="multiModify()">
  <table class='admin_table'>
    <thead>
      <tr>
        <th style='width: 1%;'><input onclick="selectAll()" type='checkbox' class='checkbox'></th>
        <th style='width: 1%;'><a href="javascript:void(0);" onclick="javascript:changeOrder('webmix_id', 'DESC');"><?php echo $this->translate("ID") ?></a></th>
        <th><a href="javascript:void(0);" onclick="javascript:changeOrder('title', 'ASC');"><?php echo $this->translate("Title") ?></a></th>
        <th style=''><a href="javascript:void(0);" onclick="javascript:changeOrder('country_id', 'ASC');"><?php echo $this->translate("Country") ?></a></th>
        <th class="" style="width: 1%;"><?php echo $this->translate('Default');?></th>
        <th class="" style="width: 1%;"><a href="javascript:void(0);" onclick="javascript:changeOrder('owner_id', 'ASC');"><?php echo $this->translate('Owner');?></a></th>
        <th class="" style="width: 1%;"><?php echo $this->translate('Count');?></th>
        <th class="" style="width: 1%;"><?php echo $this->translate('Type');?></th>
        <th style='width: 1%;' class='admin_table_options'><?php echo $this->translate("Options") ?></th>
      </tr>
    </thead>
    <tbody>
      <?php if( count($this->paginator) ): ?>
        <?php foreach( $this->paginator as $item ):?>
          <tr>
            <td><input name='modify_<?php echo $item->getIdentity();?>' value=<?php echo $item->getIdentity();?> type='checkbox' class='checkbox'></td>
            <td><?php echo $item->webmix_id ?></td>
            <td class=''><?php echo $item->title?></td>
            <td><?php $country =  $item->getCountry();
            	if($country):?>
           	    <img src="application/modules/Webmix/externals/images/flag/<?php echo strtolower($country->key)?>.png"> <?php  echo $country->title?>
            	<?php else: echo 'N/A'; endif;?>
            	</td>
            <td class=''>
             	<?php if($item->default == 1 && $item->type == 'system')echo $this->translate("Yes"); else echo $this->translate("No")?>
            </td>
            <td class=''>
             	<?php echo $item->getOwner()->__toString();?>
            </td>
            <td class='' style="text-align: center;">
                <?php echo $this->use_count[$item->getIdentity()];?>                       	
            </td>
            <td class=''>
             	<?php echo $this->translate($item->type);?>
            </td>
            <td class='admin_table_options'>
                <?php if(empty($item->default)): ?>
                <a class='smoothbox' href='<?php echo $this->url(array( 'module' => 'webmix', 'controller' => 'webmix', 'action' => 'delete', 'id' => $item->getIdentity()), 'admin_default', true);?>'>
                  <?php echo $this->translate("Delete") ?>
                </a>
                |
                <?php endif; ?>
                <a href="<?php echo $this->url(array('module'=>'webmix','controller'=>'webmix','action'=> 'edit','webmix_id'=>$item->webmix_id),'admin_default',true)?>">
                <?php  echo $this->translate("Edit") ?>

                </a>
                
                <?php if($item->type =='system' && empty($item->default)):?>
                |
                    <a class="smoothbox" href="<?php echo $this->url(array('module'=>'webmix','controller'=>'webmix','action'=> 'default','webmix_id'=>$item->webmix_id,'class'=> 'smoothbox'),'admin_default',true)?>">
                    <?php  echo $this->translate("Set default") ?>
    
                    </a>
                <?php endif;?>
                 <?php if($item->type =='system' && empty($item->public)):?>
                |
                    <a class="smoothbox" href="<?php echo $this->url(array('module'=>'webmix','controller'=>'webmix','action'=> 'public','webmix_id'=>$item->webmix_id,'class'=> 'smoothbox'),'admin_default',true)?>">
                    <?php  echo $this->translate("Publish") ?>
    
                    </a>
                <?php endif;?>
                 <?php if($item->type =='system' && !empty($item->public)):?>
                |
                    <a class="smoothbox" href="<?php echo $this->url(array('module'=>'webmix','controller'=>'webmix','action'=> 'unpublic','webmix_id'=>$item->webmix_id,'class'=> 'smoothbox'),'admin_default',true)?>">
                    <?php  echo $this->translate("Hide") ?>
    
                    </a>
                <?php endif;?>

            </td>
          </tr>
        <?php endforeach; ?>
      <?php endif; ?>
    </tbody>
  </table>
  <br />
  

  <div class='buttons'>
    <!-- <button type='submit' name="submit_button" value="approve"><?php echo $this->translate("Approve Selected") ?></button> -->
    <button type='submit' name="submit_button" value="delete"><?php echo $this->translate("Delete Selected") ?></button>
  </div>
  <br/>
   <?php echo $this->htmlLink(array('route' => 'webmix_special', 'action' => 'create'), $this->translate('Add New Webmix'), array(
      'class' => 'smoothbox buttonlink',
      'style' => 'background-image: url(' . $this->layout()->staticBaseUrl . 'application/modules/Core/externals/images/admin/new_category.png);')) ?>
</form>
</div>
<br/>
<div class='admin_results'>
  <div>
    <?php $count = $this->paginator->getTotalItemCount() ?>
    <?php echo $this->translate(array("%s webmix found", "%s webmixes found", $count),
        $this->locale()->toNumber($count)) ?>
  </div>
  <div>
    <?php echo $this->paginationControl($this->paginator, null, null, array(
      'pageAsQuery' => true,
      'query' => $this->formValues,
      //'params' => $this->formValues,
    )); ?>
  </div>
</div>